<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 会话数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\service\ChatService;
use think\Request;

class ChatController extends VerifyController
{
    /**
     * @var ChatService
     */
    private $chatService;

    public function __construct()
    {
        parent::__construct();
        $this->chatService = new ChatService();
    }

    /**
     * 获得实体聊天会话
     * @param Request $request
     * @return \think\Response
     * @throws \Exception
     */
    public function getEntityChat(Request $request)
    {
        $param = $request->param();
        $res = $this->chatService->getEntityChat($param['param']);
        return json(success_response("OK", $res));
    }


    /**
     * 获取当前用户的实体聊天会话
     * @param Request $request
     * @return \think\Response
     * @throws \Exception
     */
    public function getCurrentUserEntityChat(Request $request)
    {
        $param = $request->param();
        $res = $this->chatService->getCurrentUserEntityChat($param['param'], $request->getUnionUserId());
        return json(success_response("OK", $res));
    }
}
